<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .top-div,
        .bottom-div {
            display: flex;
            width: 500px;
            height: 200px;
        }

        .lift,
        .city {
            flex: 1;
            width: 100px;
            height: 100px;
            margin-left: 10px;
            border: 1px solid #ccc;
        }
    </style>
</head>

<body>
    <p>地下城与太空电梯</p>
    <table border="1">
        <thead>
            <tr>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>职业</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div>
        <p>太空电梯</p>
        <div class="top-div">
            <div class="lift">1</div>
            <div class="lift">2</div>
            <div class="lift">3</div>
            <div class="lift">4</div>
            <div class="lift">5</div>
        </div>
        <hr>
        <p>地下城</p>
        <div class="bottom-div">
            <div class="city">1</div>
            <div class="city">2</div>
            <div class="city">3</div>
            <div class="city">4</div>
            <div class="city">5</div>
        </div>
    </div>
    <script src="../../JQ/jquery.min.js"></script>
    <script>
        // 名单，有些人要上太空，有些人要去地下城
        let list = [
            { name: '刘培强', age: 30, sex: '1', job: '战狼' },
            { name: '韩朵朵1', age: 18, sex: '2', job: '学生' },
            { name: '韩朵朵2', age: 30, sex: '2', job: '战士' },
            { name: '韩子昂', age: 80, sex: '1', job: '退休' },
            { name: '诺夫', age: 40, sex: '1', job: '战狼' },
            { name: 'moss', age: 100, sex: '0', job: '写代码' },
            { name: '马兆', age: 50, sex: '1', job: '程序员' }
        ]

        // S生成列表
        let genTable = () => {
            let strTem = ``;
            list.map((item, i) => {
                strTem += `
                    <tr>
                        <td>${item.name}</td>
                        <td>${item.sex}</td>
                        <td>${item.age}</td>
                        <td>${item.job}</td>
                        <td><button class=btn data-index=${i}>判断</button></td>
                    </tr>
                `
            });
            let tbody = document.querySelector('tbody');
            tbody.innerHTML = strTem;
        }
        genTable()

        // 点击按钮，判断这个人去太空或者去地下城
        $('.btn').click(function () {
            $(this).parent().parent().animate({
                opacity: 0
            }, 2000);
            $('.lift').eq(0).remove()
            $('.city').eq(3).html('韩朵朵2')
        })
    </script>
</body>

</html>